#
# Makefile for the Linux 2.6 kcfs
# $Id: Makefile,v 1.16 2006/09/26 01:16:46 jsipek Exp $
#

# this is where your kernel sources are
LINUXSRC = /lib/modules/$(shell uname -r)/build
# this should point to where your kernel headers are
TOPINC = -I${LINUXSRC}/include

# Fedora Core has the annoying habit of changing the kernel prototypes on us.
FEDORAVER=$(shell rpm -q fedora-release | cut -d- -f3)
KERNELEXTRA=x$(shell uname -r | cut -d- -f 2 -s)
ifeq ($(FEDORAVER),2)
ifneq ($(KERNELEXTRA),x)
EXTRA_CFLAGS += -DFEDORACORE2
endif
endif

# allow custmom override of TOPINC and LINUXSRC
-include fistdev.mk

CC	= gcc
EXTRA_CFLAGS += -DFISTGEN -I. ${TOPINC} ${EXTRACFLAGS} -O2 -Wall -Wno-unused -fno-strict-aliasing -Werror
UCFLAGS = -DFISTGEN -I. ${TOPINC} -g -O2 -Wall -Wno-unused # -Werror

obj-m := kcfs.o
ADD_M_SRC = bf_cfb64.c bf_enc.c bf_skey.c aes.c aes_cfb128.c  fist_aux.c mmap.c md5.c
kcfs-objs :=    fist_kcfs.o \
	dentry.o file.o inode.o main.o super.o print.o \
	${ADD_M_SRC:.c=.o}

BINS	= fist_ioctl init_kcfs 

all:	${BINS}
	make -C ${LINUXSRC} SUBDIRS=$(PWD) modules


fist_ioctl: fist_ioctl.c
	${CC} -o $@ $? ${UCFLAGS}

init_kcfs: init_kcfs.c ${INIT_KCFS_SRCS}
	${CC} -o $@ $^ ${UCFLAGS} ${INIT_KCFS_OBJS}


memtest:
	perl match-malloc.pl log.txt

TAGS:
	etags -t *.[hc]

tags:
	ctags *.[hc]


clean:
	rm -f ${obj-m:.o=.ko} ${kcfs-objs} *.d .*.o.cmd .*.flags \#* *~
	rm -f ${BINS} TAGS
# dependencies
${kcfs-objs}: kcfs.h fist.h fist_kcfs.h lock.h bf_locl.h bf_pi.h blowfish.h aes.h md5.h 

# additional makefile rules, if any


